import { apiClient } from './base'

export const costDetailApi = {
  // 基础CRUD操作
  getCostDetails: (params) => apiClient.get('/fycb-dt1', { params }),
  getCostDetailById: (id) => apiClient.get(`/fycb-dt1/${id}`),
  createCostDetail: (data) => apiClient.post('/fycb-dt1', data),
  updateCostDetail: (id, data) => apiClient.put(`/fycb-dt1/${id}`, data),
  deleteCostDetail: (id) => apiClient.delete(`/fycb-dt1/${id}`),

  // 联合查询
  getCostDetailsJoin: (params) => apiClient.get('/fycb-dt1/join', { params }),
  getAllCostDetailsJoin: () => apiClient.get('/fycb-dt1/all/join'),

  // 搜索查询
  searchByFycbId: (fycbId) => apiClient.get(`/fycb-dt1/search/fycb-id?fycbId=${fycbId}`),
  searchByFyId: (fyId) => apiClient.get(`/fycb-dt1/search/fy-id?fyId=${fyId}`),
  searchByZt: (zt) => apiClient.get(`/fycb-dt1/search/zt?zt=${zt}`),
  searchByDfcb: (minDfcb, maxDfcb) => apiClient.get(`/fycb-dt1/search/dfcb?minDfcb=${minDfcb}&maxDfcb=${maxDfcb}`),
  searchByZcb: (minZcb, maxZcb) => apiClient.get(`/fycb-dt1/search/zcb?minZcb=${minZcb}&maxZcb=${maxZcb}`),

  // 统计查询
  countByZt: (zt) => apiClient.get(`/fycb-dt1/count/zt?zt=${zt}`),
  countByFycbId: (fycbId) => apiClient.get(`/fycb-dt1/count/fycb-id?fycbId=${fycbId}`),

  // Excel操作
  importExcel: (file) => {
    const formData = new FormData()
    formData.append('file', file)
    return apiClient.post('/fycb-dt1/import', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },
  exportExcel: (params) => apiClient.get('/fycb-dt1/export', {
    params,
    responseType: 'blob'
  }),
  downloadTemplate: () => apiClient.get('/fycb-dt1/export/template', {
    responseType: 'blob'
  }),

  // 测试接口
  testApi: () => apiClient.get('/fycb-dt1/test'),

  // 获取所有记录
  getAllCostDetails: () => apiClient.get('/fycb-dt1/all')
} 